-
Notifications
You must be signed in to change notification settings - Fork 287
Re-organize intrinsic-test
to enable seamless addition of behaviour testing for more architectures
#1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9900e81
to
546554d
Compare
The module should be called |
@JamieCunliffe feel free to have a look at this since you are the original author of intrinsic-test. This is part of a GSoC project to extend intrinsic-test to other architectures. |
546554d
to
3ff317f
Compare
Reasoning: 1. Majority of code assumes the usage of `Intrinsic` and related types, which is derived from the JSON structure of the ARM intrinsics JSON source file 2. Further commits will start with extracting common parts of the code (eg: Create C/Rust file, Build C/Rust file, etc)
3ff317f
to
bd0a675
Compare
…ted for different architectures. Next steps: Move the existing ARM-specific implementation into one that fits well with this trait.
5dce230
to
7ff8497
Compare
Are we using the |
a12b4a4
to
ff10311
Compare
|
3068c9d
to
2d1e482
Compare
…le_rust and compare_outputs
e0b0301
to
54a678c
Compare
54a678c
to
2777ceb
Compare
intrinsic-test
to enable seamless addition of behaviour testing for more architecturesintrinsic-test
to enable seamless addition of behaviour testing for more architectures
I have attached a diagram of the new structure of Please let me know how best I can make the review process easier, or if there are any concerns that need to be addressed. |
The basic idea with the traits is good, but I think this makes too much code arm-specific. For example, I would like to see @adamgemmell Woud you like to have a pass at reviewing this since you worked on this? |
Thank you for telling me. I think making I might need to spend some more time familiarizing myself with the x86 side of things to understand how |
* Note: setting `--sysroot=<...>` which is the obvious thing to do | ||
* does not work as it gets caught up with `#include_next <stdlib.h>` | ||
* not existing... */ | ||
format!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a good idea to make the compilation commands part common too?
Parts like:
- Include-paths, target
- Output binary
- Linking steps
- Optional cleanup step, etc
could be organized within a struct, post which we could add in functionality (in common
module) to convert the struct into the commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's a good idea. In general there will be 2 cases to consider:
- When running natively on target hardware, we can just use the host toolchain. This is what currently happens for the aarch64 tests which run on an aarch64 Github runner.
- When running emulated using qemu, we need to use a custom toolchain. We still need to use clang, but we need to point it to the C headers and libraries of the cross-compilation toolchain.
All architectures can be generalized to one of these 2 cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see
Awesome, I'll do that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running natively on target hardware, we can just use the host toolchain. This is what currently happens for the aarch64 tests which run on an aarch64 Github runner.
I don't believe this is true - stdarch still uses an x86 runner and installs the cross-compile toolchain. I think this is generally good as it means people can always run run-docker.sh
on any host which is the source of truth for CI (given some tests are sensitive to clang/objdump versions and the like)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see
|
||
/// Architectures must support this trait | ||
/// to be successfully tested. | ||
pub trait SupportedArchitectureTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may actually want to consider an Architecture
enum instead of a trait and just special casing the spots in the code that depend on the architecture. This somewhat inverts the whole design, but I personally find it much easier to work with in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am considering the shift to enums for the purpose.
d34a13a
to
2a7f631
Compare
7c686ef
to
e2444df
Compare
e2444df
to
90249a3
Compare
0d5bd59
to
1791b35
Compare
I believe it's inferred now since here where that PR added a third target. I think it can be removed. |
84d660c
to
727da8e
Compare
448e336
to
f3f4f7c
Compare
f3f4f7c
to
358016a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think types.rs would map fine to x86 with a little modification.
I'd just like to add that Scalable Vectors will be added to this tool at some point - the Arm code is here and it would probably be useful for RISC-V in the future too.
Don't worry about conflicts with that PR (it's very old and needs a rework) and I don't think there's anything particularly different about how intrinsic-test needs to work but scalable vectors do add an extra dimension of complexity to the tool.
.arg(format!("{runner} ./c_programs/{intrinsic_name}")) | ||
.output(); | ||
|
||
let rust = if SPECIAL_TARGETS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be collapsed into 1 if, it's what I did with https://github.com/rust-lang/stdarch/pull/1771/files#diff-7c34e890416eb66d4462c7f31278409c662bb808a57c3e0a4d13c232c64533a9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, let me do that.
name = "Intrinsic test tool", | ||
about = "Generates Rust and C programs for intrinsics and compares the output" | ||
)] | ||
pub struct Cli { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems an odd file name for the CLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to rename the files, I started off by focussing on the code refactor side of things.
Thank you for sharing this observation with me.
Over the last 4 commits I changed from the This allowed me to refactor a lot more code into the At the moment, each architecture can define:
I've made some changes in the C testfile-generation part, will pinpoint them in the next message. After this part, I intend to work on:
|
Updates so far
arm
module, exposing only atest
function atsrc/main.rs
SupportedArchitectureTest
trait that has been implemented forarm
and should be implemented for other architectures too. Allows us to expose functionality like building C/Rust test files and comparing outputs.common
module for reuse by other architectures too.match
block for selection of architectures using thetarget
CLI variable.Reasoning
Intrinsic
type may be specific to architectures, hence the implementation of a trait helps us to abstract the usage of such data types within the architecture-specific moduleNew architecture of
intrinsic-test